package view;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;

import controller.ZoomListener;

public class ToolBar extends JPanel {

    private static final long serialVersionUID = -3978021186656483972L;

    private JSlider jsZoom = new JSlider();
    private JLabel lblZoom = new JLabel("100%");

    public ToolBar() {

	super(new FlowLayout(FlowLayout.LEFT)); // Left align components

	add(new JLabel("Zoom"));

	// Setup zoom
	jsZoom.setValue(100); // 5 increments
	jsZoom.setMinorTickSpacing(25);
	jsZoom.setMajorTickSpacing(50);
	jsZoom.setSnapToTicks(true);
	jsZoom.setPaintTicks(true);
	jsZoom.setMinimum(50);
	jsZoom.setMaximum(200);
	jsZoom.setPreferredSize(new Dimension(200, 30));
	jsZoom.addChangeListener(new ZoomListener());
	add(jsZoom);

	add(lblZoom);
    }

    public int getZoom() {
	return jsZoom.getValue();
    }

    public void setZoom(int value) {
	jsZoom.setValue(value);
    }

    public void setZoomLabel(String text) {
	lblZoom.setText(text);
    }

}
